<?php
//echo $this->Form->create();
$tools=$formData['tools'];
$toolsTable=$formData['toolsTable'];

?>
    <fieldset>
        <legend><?php __('Which Tools does the User need ?'); ?></legend>

        <div class="toolNb isHidden">1</div>
        <div class="maxNb isHidden"><?php  echo count($tools); ?></div>
<?php
             for ($i=0;$i<count($tools);$i++){
                 if($i==0):
                    echo '<div class="tool'.$i.' relative">';
    ?>
                    <fieldset>
                        <legend><?php __('Tool ');  echo $i+1;  ?></legend>                    
    <?php               echo $this->Form->input('tool_id'.$i,array('options'=>$tools,'empty'=>'select','label'=>array('text'=>__('Tool',true),'class'=>'required'),'class'=>'toolList','id'=>'DmdformUserToolId'.$i));
                    ?>
                        <div class="isHidden toolsTable"><?php 
                            echo $this->Form->input('tool_table'.$i,array('options'=>$toolsTable,'empty'=>'select','label'=>array('text'=>__('tables',true)),'class'=>'toolTables','id'=>'toolTables'.$i));
                            echo $this->Form->input('toolTableName'.$i,array('type'=>'text','id'=>'toolTableName'.$i));
                            echo $this->Form->input('toolTableData'.$i,array('type'=>'text','id'=>'toolTableData'.$i));
                        ?></div>
                        <h2 class="showNextDiv isHidden pointer" id="formContainerBtn<?php echo $i;  ?>">Specific Form</h2>
                        <div class="isHidden" id="formContainer<?php echo $i;  ?>">
                            
                        </div>
                    </fieldset>
    <?php           echo '</div>';
                
                else:
                        echo '<div class="tool'.$i.' isHidden relative">';
    ?>
                    <fieldset>
                        <legend><?php __('Tool ');  echo $i+1;  ?></legend>                    
    <?php                echo $this->Form->input('tool_id'.$i,array('options'=>$tools,'empty'=>'select','label'=>__('Tool',true),'class'=>'toolList','id'=>'DmdformUserToolId'.$i));
                    ?>
                        <div class="isHidden toolsTable"><?php 
                            echo $this->Form->input('tool_table'.$i,array('options'=>$toolsTable,'empty'=>'select','label'=>array('text'=>__('tables',true)),'class'=>'toolTables','id'=>'toolTables'.$i));
                            echo $this->Form->input('toolTableName'.$i,array('type'=>'text','id'=>'toolTableName'.$i));
                            echo $this->Form->input('toolTableData'.$i,array('type'=>'text','id'=>'toolTableData'.$i));
                        ?></div>
                        <h2 class="showNextDiv isHidden pointer" id="formContainerBtn<?php echo $i;  ?>">Specific Form</h2>
                        <div class="isHidden" id="formContainer<?php echo $i;  ?>">
                            
                        </div>
                    </fieldset>
    <?php           echo '</div>';
                endif;
             
             }
?>
        <table class="nn">
            <tr>
                <td><div class="showNextBtn addTool" ><?php __('Add a Tool')  ?></div></td>
                <td><div class="showNextBtn removeTool isHidden" ><?php __('Remove Tool')  ?></div></td>
            </tr>
        </table>

    </fieldset>
<?php
//echo $this->Form->end('submit');
?>

<script type="text/javascript">
    

</script>

